package com.code;

import com.example.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LoginConfig extends Activity{
	private EditText etUser, etPass;
	private Button btLogin, btCancel;
	private final int REQUESTCODE_LOGIN = 101;
	public static Boolean login = false;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.loginconfig);
		
		etUser = (EditText) findViewById(R.id.etUserConfig);
		etPass = (EditText) findViewById(R.id.etPassConfig);
		btLogin = (Button) findViewById(R.id.btLoginConfig);
		btCancel = (Button) findViewById(R.id.btCancelConfig);

		btLogin.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (etUser.getText().toString().equals("admin") 
						&& etPass.getText().toString().equals("admin")) {
					Toast.makeText(LoginConfig.this, "Đăng nhập thành công!",
							Toast.LENGTH_LONG).show();
						startActivityForResult(new Intent(LoginConfig.this,
								Login.class), REQUESTCODE_LOGIN);
						login = true;
					finish();
				} else {
					Toast.makeText(LoginConfig.this, "Đăng nhập thất bại!",
							Toast.LENGTH_LONG).show();
				}
			}
		});

		btCancel.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				// TODO Auto-generated method stub
				setResult(RESULT_CANCELED);
				finish();
			}
		});

	}
}
